{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 解读 `ExprDeepEqual` \n",
    "\n",
    "源码：`tvm/tir/analysis.h`\n",
    "\n",
    "```c++\n",
    "/*!\n",
    " * \\brief Compare two expressions recursively and check if they are equal\n",
    " *        to each other without var remapping.\n",
    " *\n",
    " *  This function does not remap variable bindings, it will not\n",
    " *  return true for (let x = 1 in x + 1) vs (let y = 1 in y + 1), unless x.same_as(y).\n",
    " *\n",
    " *  Use StructuralEqual for such cases.\n",
    " *\n",
    " *  Due to the restriction of not remapping variables, this function can run\n",
    " *  faster than StructuralEqual and can be used as a utility function during arithmetic\n",
    " *  simplifications.\n",
    " *\n",
    " * \\sa StructuralEqual\n",
    " */\n",
    "struct ExprDeepEqual {\n",
    " public:\n",
    "  TVM_DLL bool operator()(const PrimExpr& lhs, const PrimExpr& rhs) const;\n",
    "};\n",
    "```\n",
    "\n",
    "`ExprDeepEqual` 结构体，它用于比较两个表达式是否相等。该结构体包含公共成员函数 `operator()`，接受两个参数 `lhs` 和 `rhs`，分别表示要比较的两个表达式。\n",
    "\n",
    "该函数的作用是递归地比较两个表达式是否相等，但不进行变量重映射。也就是说，如果两个表达式在不改变变量绑定的情况下相等，则返回 `true`；否则返回 `false`。\n",
    "\n",
    "```\n",
    "return true for (let x = 1 in x + 1) vs (let y = 1 in y + 1), unless x.same_as(y).\n",
    "```\n",
    "\n",
    "需要注意的是，由于该函数不进行变量重映射，因此在某些情况下可能比 `StructuralEqual` 运行得更快，并且可以作为算术简化过程中的实用函数使用。\n",
    "\n",
    "另外，该函数还提供了相关参考文档 `\\sa StructuralEqual`，可能是为了说明在某些情况下可以使用 `StructuralEqual` 来进行更复杂的变量映射比较。"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
